package com.zrfintech.manage.util;


import com.zrfintech.manage.constant.ErrorCode;
import com.zrfintech.manage.vo.HttpResponse;

public class HttpResponseUtil {
    public static HttpResponse success() {
        return new HttpResponse<>(ErrorCode.OK, null, "OK");
    }

    public static HttpResponse success(Object data) {
        return new HttpResponse<>(ErrorCode.OK, data, "OK");
    }

    public static HttpResponse loginError(String loginUrl) {
        return new HttpResponse<>(ErrorCode.NO_LOGIN, null, "未登录,<a href=\"" + loginUrl + "\">去登陆</a>");
    }

    public static HttpResponse loginError() {
        return new HttpResponse<>(ErrorCode.NO_LOGIN, null, "");
    }

    public static HttpResponse error(int code, String msg) {
        return new HttpResponse<>(code, null, msg);
    }


    public static HttpResponse HttpResponse(int code, Exception e) {
        return new HttpResponse<>(code, null, e.getMessage(), e.getClass().getSimpleName());
    }


}
